package cn.sixmillions.yuqueblog.controller;

import cn.sixmillions.yuqueblog.entity.Doc;
import cn.sixmillions.yuqueblog.entity.DocDetail;
import cn.sixmillions.yuqueblog.service.IDocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 语雀文档API
 * @author: sixmillions
 * @since: 2021/12/10
 **/
@RestController
@RequestMapping("/api/doc")
@Api(value = "Doc Controller", tags = "Doc")
public class DocController {

    @Autowired
    private IDocService docService;

    @GetMapping("/list")
    @ApiOperation(value = "List", notes = "一个仓库的文档列表")
    public List<Doc> getDocs(String namespace) {
        return docService.getDocs(namespace);
    }

    @GetMapping
    @ApiOperation(value = "Doc", notes = "单篇文档的详细信息")
    public DocDetail detail(String namespace, String slug) {
        return docService.detail(namespace, slug);
    }
}
